import pandas as pd
import requests

target_url = 'http://127.0.0.1:3000/book/'

if __name__ == '__main__':
    excel_path = r"C:\Users\31956\Desktop\1.总库.xlsx"
    raw_data = pd.read_excel(excel_path)
    # raw_data = raw_data.drop(columns=['网络资源'], axis=1)
    raw_data.columns = ['code', 'name', 'institute', 'major', 'credit', 'period', 'characteristics', 'courseType',
                        'prerequisite', 'textbook', 'textbookFormatInfo', 'textbookWebsite', 'reference',
                        'referenceFormatInfo',
                        'referenceWebsite', 'newestReference', 'newestReferenceWebsite']
    for i in range(raw_data.size):
        try:
            a_row_data = raw_data.iloc[i]
            dict_data = a_row_data.to_dict()
            print(dict_data)
            requests.post(target_url, data=dict_data)
        except:
            continue
